package love.simbot.example.utils.chatRobot;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.ktor.util.Hash;
import love.simbot.example.entity.chatRobot.ChatRobot;
import love.simbot.example.entity.chatRobot.MoliChatRobot;
import love.simbot.example.utils.http.HttpUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import sun.net.www.http.HttpClient;

import java.util.HashMap;

// 聊天机器人
public abstract class ChatRobotUtils {


    // 小爱同学
    private static final String CHAT_HTTP1 = "http://ruohuan.xiaoapi.cn/API/other/xiaoai.php";

    // 茉莉机器人
    private static final String CHAT_HTTP2 = "https://api.mlyai.com/reply";



    // 聊天模式
    public static ChatRobot getChatMessage(String content){

        HashMap<String,Object> params = new HashMap<>();
        params.put("msg",content);

        ObjectMapper om = new ObjectMapper();
        om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);

        ChatRobot chatRobot = null;
        try {
            String result = HttpUtils.getTool(CHAT_HTTP1, params);
            chatRobot = om.readValue(result,ChatRobot.class);
        }catch (Exception e){
            e.printStackTrace();
        }

       return  chatRobot;
    }




}
